package io.github.talelin.latticy.common.pojo;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

/**
 * 分页父类
 */
@Data
public class BasePage {

    /**
     * 当前页
     */
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private Integer currPage = 0;

    /**
     * 页数量
     */
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private Integer pageSize = 20;


    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private Integer pageNum;

    public Integer getPageNum() {
        if (currPage != null) {
            return (currPage - 1) * pageSize;
        }
        return pageNum;
    }
}
